//
//  AYSLeftViewController.m
//  AiYingShiProject
//
//  Created by lanou on 15/10/30.
//  Copyright (c) 2015年 李晓理. All rights reserved.
//

#import "AYSLeftViewController.h"
#import "AYSSideViewController.h"
#import "AYSLeftTableViewCell.h"

#import "AYSRootViewController.h"

#import "AYSSideViewController.h"
#import "AYSRootViewController.h"
@interface AYSLeftViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *mainTbaleView;
@property (nonatomic,strong) NSMutableArray *dataArray;
@property (nonatomic,strong) NSMutableArray *pictureArray;
@property (nonatomic,strong) NSMutableArray *classArray;


//@property (nonatomic,strong) AYSRootViewController *rootVC;
@property (nonatomic,strong) UINavigationController *naVC;

@end

@implementation AYSLeftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    [self configureView];
    _dataArray = [NSMutableArray arrayWithObjects:@"观看记录",@"收藏",@"接收消息",@"意见反馈",@"关于爱影视", nil];
    NSData *record = UIImagePNGRepresentation([UIImage imageNamed:@"record"]);
    NSData *download = UIImagePNGRepresentation([UIImage imageNamed:@"download"]);
    NSData *changecolor = UIImagePNGRepresentation([UIImage imageNamed:@"changecolor"]);
    NSData *language = UIImagePNGRepresentation([UIImage imageNamed:@"language"]);
    NSData *statement = UIImagePNGRepresentation([UIImage imageNamed:@"statement"]);
    NSData *anoutus = UIImagePNGRepresentation([UIImage imageNamed:@"anoutus"]);
    _pictureArray = [NSMutableArray arrayWithObjects:record,download,changecolor,language,statement,anoutus, nil];
    // 注册cell
    [_mainTbaleView registerClass:[AYSLeftTableViewCell class] forCellReuseIdentifier:@"leftView"];
    
   
}

// 配置页面
- (void)configureView
{
    UIImageView *backView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    backView.image = [UIImage imageNamed:@"back1"];
    [self.view addSubview:backView];
    
    _mainTbaleView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH - 75, SCREEN_HEIGHT) style:(UITableViewStyleGrouped)];
    _mainTbaleView.delegate = self;
    _mainTbaleView.dataSource = self;
    _mainTbaleView.backgroundColor = [UIColor clearColor];
    _mainTbaleView.userInteractionEnabled = YES;
    [self.view addSubview:_mainTbaleView];
    

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AYSLeftTableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:@"leftView" forIndexPath:indexPath];
    if (indexPath.row == 2)
    {
        cell.titleLabel.text = _dataArray[indexPath.row];
        cell.titleLabel.textColor = [UIColor whiteColor];
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
         cell.iconImageView.image =[UIImage imageWithData:_pictureArray[indexPath.row]];
        UISwitch *myswitch = [[UISwitch alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 150, 5, 20, 20)];
        [cell.contentView addSubview:myswitch];
        return cell;
    }
    else
    {
    cell.titleLabel.text = _dataArray[indexPath.row];
    cell.titleLabel.textColor = [UIColor whiteColor];
    cell.backgroundColor = [UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.iconImageView.image =[UIImage imageWithData:_pictureArray[indexPath.row]];
    cell.arrowImageView.image = [UIImage imageNamed:@"right"];
        return cell;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushVC" object:nil userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"%ld", indexPath.row] forKey:@"row"]];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
